<?php 
$www_root = dirname(dirname(dirname(__FILE__))).'/';
require_once $www_root.'protected/config/main.php'; $DB->conn(); 

if($user->Authenticate_User()){

$query = sprintf("INSERT INTO tbl_log_message (user_id, title, message, address, lat, lng, log_date, updated_on, status) VALUES (%s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", 
        $user->id,
        mysql_real_escape_string($_POST['txt_title']),
        mysql_real_escape_string($_POST['txt_message']),
        mysql_real_escape_string($_POST['txt_address']),
        mysql_real_escape_string($_POST['txt_lat']),
        mysql_real_escape_string($_POST['txt_lng']),
        mysql_real_escape_string($_POST['txt_date']),
        date('Y-m-d H:i:s',time()),
        1);
        $result = mysql_query($query);
        if (!$result) {
            $message  = 'Invalid query: ' . mysql_error() . "\n";
            $message .= 'Whole query: ' . $query;
            die($message);
        }
        else echo 1;
}

$DB->close();
?>